package com.easybuilder.common.utils;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class Base64Util {

    /** base64解密 */
    public static String decode(String msg) {
        Base64.Decoder decoder = Base64.getDecoder();
        byte[] decode = decoder.decode(msg);
        return new String(decode);
    }

    /** base64加密 */
    public static String encode(String msg) {
        if (StringUtil.isEmpty(msg)) {
            return "";
        }
        Base64.Encoder encoder = Base64.getEncoder();
        byte[] encode = encoder.encode(msg.getBytes(StandardCharsets.UTF_8));
        return new String(encode);
    }

}
